<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../react18/react.development.js"></script>
    <script src="../react18/react-dom.development.js"></script>
    <script src="../react18/babel.min.js"></script>
</head>

<body>
    <div id="app"></div>

    <script type="text/babel">
        /*
        组件实例有一个state属性,当state属性的状态发生变化时,会触发render函数,render函数会返回一个新的虚拟DOM,diffing算法开始计算
        
        */
        class App extends React.Component{
            state = {
                name: "张三",
                age: "20",
                eat: "吃遍大江南北",
                play: "玩遍四海八荒"
            }

            render(){
                console.log(this);//实例有context/props/refs/state/updater属性
                const {name,age,eat,play} = this.state
                return (
                    <div>
                        <h3>个人简介</h3>
                        <p>{name}</p>
                        <p>{age}</p>
                        <p>{eat}</p>
                        <p>{play}</p>
                    </div>

                )
            }

        }

        const root = ReactDOM.createRoot(document.getElementById("app"))
        root.render(<App />)
    </script>
</body>

</html>